﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VB2CS
{
    public sealed class Versioned
    {
        public static bool IsNumeric(object Expression)
        {
            IConvertible convertible = Expression as IConvertible;
            if (convertible != null)
            {
                switch (convertible.GetTypeCode())
                {
                    case TypeCode.Boolean:
                        return true;

                    case TypeCode.Char:
                    case TypeCode.String:
                        {
                            double num;
                            string str = convertible.ToString(null);
                            try
                            {
                                long num2=0;
                                if (Utils.IsHexOrOctValue(str, ref num2))
                                {
                                    return true;
                                }
                            }
                            catch (FormatException)
                            {
                                return false;
                            }
                            //return Conversions.TryParseDouble(str, ref num);
                            return double.TryParse(str,out num);                            
                        }
                    case TypeCode.SByte:
                    case TypeCode.Byte:
                    case TypeCode.Int16:
                    case TypeCode.UInt16:
                    case TypeCode.Int32:
                    case TypeCode.UInt32:
                    case TypeCode.Int64:
                    case TypeCode.UInt64:
                    case TypeCode.Single:
                    case TypeCode.Double:
                    case TypeCode.Decimal:
                        return true;
                }
            }
            return false;
        }

    }
}
